var clientUtils = angular.module('clientUtils');

clientUtils.factory('Constant', ['$location', function($location) {
    var PAGE_SIZE = 6;
    var SERVICE_URL_DEVELOP  = "http://localhost:9000/";
    var SERVICE_URL_PRODUCTION = "http://56.io/"
    var UploadUrl = "http://localhost:9090";

    var ApiVer = 'v1';
    var ApiPath = 'N/A';
    var CmsRoot = 'N/A';
    var ClientRoot = 'N/A';

    var url = $location.absUrl();
    if (url.indexOf("localhost") > -1 || url.indexOf("192.168") > -1 || url.indexOf("10.0") > -1) {
        ApiPath =  SERVICE_URL_DEVELOP + 'api/' + ApiVer + '/';
        if (url.indexOf("dist") > -1) {   // build testing
            CmsRoot = SERVICE_URL_DEVELOP + 'dist/cms/';
            ClientRoot = SERVICE_URL_DEVELOP + 'dist/client/';
        } else {    // develop
            CmsRoot = SERVICE_URL_DEVELOP + 'cms/';
            ClientRoot = SERVICE_URL_DEVELOP + 'client/';
        }
    } else {    // production
        ApiPath =  SERVICE_URL_PRODUCTION + 'api/' + ApiVer + '/';
        CmsRoot = 'http://56.io/cms/';
        ClientRoot = 'http://56.io/c/';
    }

    return {
        PAGE_SIZE: PAGE_SIZE,
        ApiVer: ApiVer,
        ApiPath: ApiPath,
        CmsRoot: CmsRoot,
        ClientRoot: ClientRoot,
        UploadUrl: UploadUrl,

        HTTP_RETURN_CODE_SUCCESS: 1,
        HTTP_RETURN_CODE_FAIL: 0,
        HTTP_RETURN_CODE_NO_MORE: -100
    };
}]);

clientUtils.factory('Vari', [function() {
    return {
        CurrentAppId: null
    };
}]);